#define _CRT_SECURE_NO_WARNINGS
#include"Heap.h"
void AdjustUp(HPDataType* a, int child)
{
	int parent = child / 2;
	while (parent >= 0 && a[child] > a[parent])
	{
		Swap(&a[child], &a[parent]);
		child = parent;
		parent = child / 2;
	}
}

void AdjustDown(HPDataType* a, int n, int parent)
{
	int child = parent * 2 + 1;
	while (child < n)
	{
		if (child + 1 < n && a[child] < a[child + 1])
		{
			child++;
		}
		if (a[child] > a[parent])
		{
			Swap(&a[child], &a[parent]);
			parent = child;
			child = parent * 2 + 1;
		}
		else
		{
			break;
		}
	}
}
void Swap(HPDataType* p1, HPDataType* p2)
{
	HPDataType tmp = *p1;
	*p1 = *p2;
	*p2 = tmp;
}